﻿using System;
using System.Collections.Generic;
using Needle.Core;

namespace Needle.Bus.Engine.Factories
{
    public class NeedleFactory<T> : IFactory<T>
    {

        IKernel _kernel;

        /// <summary>
        /// Initializes a new instance of the NeedleStageFilterLoader class.
        /// </summary>
        /// <param name="kernel"></param>
        public NeedleFactory(IKernel kernel)
        {
            if (kernel == null)
                throw new ArgumentNullException("kernel", "kernel is null.");

            _kernel = kernel;
        }

        public T Create(string id)
        {
            return _kernel.GetInstance<T>(id);
        }

        public IList<T> CreateAll()
        {
            throw new NotSupportedException();
        }
    }
}
